package com.xiaoyy.core.common.enums;
/**
 * 错误码
 * @author chenzh
 * @date 2018-08-12
 * */
public enum ErrorEnum implements BaseError{
    SYSTEM_ERROR_NO_LONIN(401, "", "未登录"),
    SYSTEM_ERROR_NO_BIND(40102, "", "未绑定账号"),
    SYSTEM_ERROR_ALREAD_BIND(40103, "", "该微信已绑定账号"),
    SYSTEM_ERROR_SHOW_IMG_CODE(40101, "showImgCode", "请输入图片验证码"),
    SYSTEM_ERROR_NO_PRIVILEGE(403, "", "没有权限"),
    SYSTEM_ERROR(999999, "error", "系统错误");
    private final Integer code;
    private final String extCode;
    private final String message;

    ErrorEnum(Integer code, String extCode, String message) {
        this.code = code;
        this.extCode = extCode;
        this.message = message;
    }

    @Override
    public Integer getCode() {
        return code;
    }

    @Override
    public String getExtCode() {
        return extCode;
    }

    @Override
    public String getMessage() {
        return message;
    }

    public static ErrorEnum getErrorByCode(int code) {
        for (ErrorEnum errorEnum : values()) {
            if (errorEnum.getCode() == code) {
                return errorEnum;
            }
        }
        return null;
    }
}
